how to get varchar as byte[] using DataReader in Ado.Net?
Posted
by Krishna
on Stack Overflow
See other posts from Stack Overflow
or by Krishna
Published on 2010-03-31T13:31:06Z
Indexed on
2010/03/31
13:33 UTC
Read the original article
Hit count: 311
ADO.NET
how to get varchar as byte[] data using DataReader in Ado.Net? We have tried the following code.
if (!objDataReader.IsDBNull(i))
{
long len = objDataReader.GetBytes(i, 0, null, 0, 0);
byte[] buffer = new byte[len];
objDataReader.GetBytes(i, 0, buffer, 0, (int)len);
}
But the above code gives the error ("Unable to cast object of type 'System.String' to type 'System.Byte[]'.")
© Stack Overflow or respective owner